package ferp.android.activities.preferences;

import android.content.Context;
import android.preference.CheckBoxPreference;
import android.util.AttributeSet;
import android.view.View;

/**
 * User: olegs
 * Date: 8/17/12 9:26 AM
 */
public class CheckBox extends CheckBoxPreference
{
  public static CheckBox setup(Preferences owner, int key, boolean checked, boolean enabled)
  {
    CheckBox preference = owner.find(CheckBox.class, key);

    preference.setChecked(checked);
    preference.setOnPreferenceChangeListener(owner);
    preference.setEnabled(enabled);

    return preference;
  }

  public CheckBox(Context context)
  {
    this(context, null);
  }

  public CheckBox(Context context, AttributeSet attrs)
  {
    super(context, attrs);
  }

  @Override
  protected void onBindView(View view)
  {
    super.onBindView(view);

    Preferences.initializePreferenceStyle(view, isEnabled());
  }
}
